package com.itheima.order.controller;

import com.itheima.order.entity.OrderEntity;
import com.itheima.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    //根据用户id查询订单列表
    @GetMapping("/findOrderInfoByUserId/{userId}")
    public List<OrderEntity> findOrderInfoByUserId(@PathVariable("userId") Integer userId){
        return orderService.findOrderInfoByUserId(userId);
    }

    //添加订单
    @PostMapping("/addOrder")
    public boolean addOrder(@RequestBody OrderEntity orderEntity){
        return orderService.addOrder(orderEntity);
    }


}
